import { BasicColumn } from '@/components/Table';
import { h, ref } from 'vue';
import { CaretDownFilled } from '@ant-design/icons-vue';
// 自定义过滤图标的方法
// 定义 filterIcon 方法
const filterIcon = (filtered, onFilter, column) => {
  // console.log(filtered, onFilter, column)
  return h(CaretDownFilled, {
    style: {
      color: filtered ? '#ABBACD' : undefined,
      fontSize: '15px'
    },
    onClick: () => onFilter(null, column),
  });
};

// 获取当前状态
const getStatus = ref()
export function getStatusFun(status) {
  getStatus.value = status
  console.log('getStatusFun', getStatus.value)
}

//table
export const columns: any = [
  {
    title: '培训期数',
    dataIndex: 'trainingNumberName',
    key: 'trainingNumberName',
    customFilterDropdown: true,
    formType: 'select',
    onFilter: (value, record) => record.name.toString().toLowerCase().includes(value.toLowerCase()),
    onFilterDropdownOpenChange: (visible) => {
      if (visible) {
      }
    },
    filterIcon,
    otherFormType: 'search',
    params: 'trainingNumberIds',
    width: 140
  },

  {
    title: '状态',
    dataIndex: 'status',
    key: 'status',
    customFilterDropdown: true,
    onFilter: (value, record) =>
      record.name.toString().toLowerCase().includes(value.toLowerCase()),
    onFilterDropdownOpenChange: (visible) => {
      if (visible) {
        console.log('789');
      }
    },
    filterIcon,
    formType: 'select',
    otherFormType: 'search',
    params: 'statusList',
    width: 140
  },
  {
    title: '培训时间',
    dataIndex: 'trainingTime',
    key: 'trainingTime',
    width: 250,
    defaultSortOrder: 'descend',
    formType: 'time',
    customFilterDropdown: true,
    filterIcon,
    params: ['trainingStartTime', 'trainingEndTime'],
  },
  {
    title: '考核时间',
    dataIndex: 'examineTime',
    key: 'examineTime',
    width: 250,
    defaultSortOrder: 'descend',
    ifShow: () => {
      return getStatus.value != 3
    },
    formType: 'time',
    customFilterDropdown: true,
    filterIcon,
    params: ['accessStartTime', 'accessEndTime']
  },
  {
    title: '约培人数',
    dataIndex: 'appointmentNumber',
    key: 'appointmentNumber',
    width: 100
    // sorter: true,
  },
  {
    title: '到培人数',
    dataIndex: 'arrivalNumber',
    key: 'arrivalNumber',
    // sorter: true,
    ifShow: () => {
      return getStatus.value >= 1
    },
    width: 100
  },
  {
    title: '过培人数',
    dataIndex: 'acceptedNumber',
    key: 'acceptedNumber',
    // sorter: true,
    ifShow: () => {
      return getStatus.value == 3
    },
    width: 100
  },
  {
    title: '中途劝退',
    dataIndex: 'rejectedNumber',
    key: 'rejectedNumber',
    // sorter: true,
    ifShow: () => {
      return getStatus.value >= 1
    },
    width: 100
  },
  {
    title: '中途放弃',
    dataIndex: 'declinedNumber',
    key: 'declinedNumber',
    // sorter: true,
    ifShow: () => {
      return getStatus.value >= 1
    },
    width: 100
  },
  {
    title: '过培率',
    dataIndex: 'acceptedRate',
    key: 'acceptedRate',
    // sorter: true,
    ifShow: () => {
      return getStatus.value == 3
    },
    width: 100
  },
  {
    title: '编辑',
    dataIndex: 'edit',
    fixed: 'right',
    key: 'edit',
    tooltip: '约培人数为0时可删除',
    ifShow: () => {
      return getStatus.value != 3
    },
    width: 80
  },
  {
    title: '上线',
    dataIndex: 'online',
    fixed: 'right',
    key: 'online',
    tooltip: '1、培训下线后学生端不可见，网申后台可见，可预约。修改后即时生效，请谨慎操作。2、学生端展示所有已上线培训的前两期。',
    ifShow: () => {
      return getStatus.value === 0
    },
    width: 100
  },
]
